package com.ash.service.comment;

import com.ash.domain.Comment;
import com.ash.domain.vo.CommentVo;
import com.ash.mapper.comment.CommentMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author : Chen Chao
 * @encoding : UTF-8
 * @date : 2021/4/5 22:28
 * @file : project06.com.ash.service.comment.CommentServiceImpl.java
 * @software : IntelliJ IDEA
 * @since : 1.8
 */
@Service
public class CommentServiceImpl implements CommentService {
    @Resource
    CommentMapper commentMapper;
    @Override
    public List<CommentVo> selectByBid(Integer bid, Integer page, Integer limit, String order) {
        if(page!=null&&limit!=null){
            return commentMapper.selectByBid(bid, (page-1)*limit, limit, order);
        }else {
            return commentMapper.selectByBid(bid, page, limit, order);
        }
    }
    @Override
    public Integer selectDataCount(Integer bid) {
        return commentMapper.selectDataCount(bid);
    }

    @Override
    public Integer add(Comment comment) {
        return commentMapper.add(comment);
    }
}
